package demo.socket;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

public class StringClient {

	public static void main(String[] args) {
		try {
			Socket socket = new Socket(InetAddress.getLocalHost(), 10000);
			PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
			BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			Scanner sc = new Scanner(System.in);
			String str = null;
			while (!(str = sc.nextLine()).equals("quit")) {
				pw.println(str);
				System.out.println(br.readLine());
			}
			sc.close();
			socket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
